SET CENT ON
set proc to sospro
set proc to boxproc
DR='N:'
STORE ' ' TO AEANAME,AEAADDR,AEACITY,AEACOUN,AEACURR
STORE .F. TO AEAHEAL,AEADECI
DO START

  set function 10 to space(4)
  dr='n:'
  f1='supplier'
  use
  set exclu off
  use &dr&f1 index &dr&f1
  go bottom
  set colo to bg+/b,w+/n
CLEAR
SET COLO TO BG+/B,w+/n
DO ADDRESSS
DO ADDRTITL WITH 'S U P P L I E R   E N T R Y   &   U P D A T E'
  SET COLO TO BG+/B,w+/n
  set inte off
  @ 10, 5 say 'CODE           :'
  @ 10,28 SAY 'NAME        :'
  @ 11, 5 say 'ADDRESS        :'
  @ 14, 5 SAY 'CITY           :'
  @ 15, 5 say 'TELP 1         :'
  @ 16, 5 SAY 'TELP 2         :'
  @ 17, 5 SAY 'TELP 3         :'
  @ 18, 5 SAY 'FAX & TELEX    : '+SPAC(17)+'/'
  @ 19, 5 SAY 'CONTACT PR.    :'
  @ 20, 5 say 'P.P.N.   (Y/N) :'
  @ 21, 5 say 'PAYMENT        :      DAYS'
  @ 21,37 say 'CURRENCY   :'
*  set color to w
  LORG=SAVESCREEN(0,0,24,79)
  del_rec = 'N'
  option = 1
  do while option <>9
    set deli off
    record_no = recno()
    kode     = supp_code
    name     = supp_name
    curr     = supp_curr
    SCUR     = SUPP_CURR
    tel1     = supp_tel1
    tel2     = supp_tel2
    tel3     = supp_tel3
    fax      = supp_fax
    telex    = supp_telex
    add1     = supp_add1
    add2     = supp_add2
    city     = supp_city
    cont_pr  = contact_p
    disc     = discount
    prdisc   = disc_perc
    termpay  = term_paymt
    if ppn=.T.
     ppn_yn   = 'Y'
    else
     ppn_yn   = 'N'
    endif
   SET COLO TO GR+/B,w+/B
*    SET COLO TO
    @ 10,22 say kode
    @ 10,42 say name
    @ 12,05 say add1
    @ 13,05 say add2
    @ 14,22 say city
    @ 15,22 say tel1
    @ 16,22 say tel2
    @ 17,22 say tel3
    @ 18,22 say fax
    @ 18,41 SAY telex
    @ 19,22 say cont_pr
    @ 20,22 say ppn_yn
    @ 21,22 say termpay PICT '999'
    @ 21,50 SAY CURR

    do mn_formM
    do case
      case option = 1    && get
          LYYY=SAVESCREEN(0,0,24,79)
           SET INTEN ON
           COCOD=SPACE(4)
           CONAM=SPACE(20)
           compin=space(5)
           DO BOXE WITH 15,33,'Enter Initial of Supplier Name :','COMPIN','W+','RB','W+','N',5,.F.,.T.
           if lastkey()=27
              RESTSCREEN(0,0,24,79,LYYY)
              LOOP
           endif
           DO SUPP401
           SNAME=CONAM
           SET INDE TO &DR&F1
           SEEK SNAME
           IF EOF()
               LAYAR=SAVESCREEN(0,0,24,79)
               set colo to W+/b,w+/B
               @ 23,09 clea to 23,69
               @ 23,10 SAY 'NOT EXIST'
               WAIT ' '
               RESTSCREEN(0,0,24,79,LYYY)
               GO BOTT
               loop
            endif
            RESTSCREEN(0,0,24,79,LORG)
      case option = 2
        go top
      case option = 3
        go bottom

      case option = 4
        skip
        if eof()
          go bottom
          LAYAR=SAVESCREEN(0,0,24,79)
          set colo to W+/b,w+/B
          @ 23,09 clea to 23,69
          @ 23,10 SAY 'LAST RECORD'
          WAIT ' '
          SET COLO TO
          RESTSCREEN(0,0,24,79,LAYAR)
        endif

      case option = 5
        skip -1
        if bof()
          go top
          LAYAR=SAVESCREEN(0,0,24,79)
          set colo to W+/b,w+/B
          @ 23,09 clea to 23,69
          @ 23,10 SAY 'FIRST RECORD'
          WAIT ' '
          SET COLO TO
          RESTSCREEN(0,0,24,79,LAYAR)
        endif
      case option = 6
           SET COLO TO W+/N,W+/N
           SET DELI OFF
*           SET INTE ON
           @ 10,42 GET name PICT '@!'
           @ 12,05 GET add1 PICT '@!'
           @ 13,05 GET add2 PICT '@!'
           @ 14,22 GET city PICT '@!'
           @ 15,22 GET tel1 PICT '@!'
           @ 16,22 GET tel2 PICT '@!'
           @ 17,22 GET tel3 PICT '@!'
           @ 18,22 GET fax
           @ 18,41 GET telex
           @ 19,22 GET cont_pr
           DO WHILE .T.
             @ 20,22 GET ppn_yn PICT '@!'
             READ
             IF PPN_YN='Y' .OR. PPN_YN='N'
                EXIT
             ENDIF
           ENDDO
           @ 21,22 get termpay PICT '999'
          read
          LYRA=SAVESCREEN(0,0,24,79)

          F2='CURRENCY'
          SELE 2
          SET EXCLU OFF
          USE &DR&F2
          COUNT TO CNT
          DECLARE FILD[CNT]
          DECLARE CURC[CNT]
          GO TOP
          CR=0
          DO WHILE .NOT. EOF()
             CR=CR+1
             FILD[CR]=SUBS(CURR_COUN,1,14)+' '+CURR_CODE
             CURC[CR]=CURR_CODE
             SKIP
          ENDDO
          set colo to w/b
          inkey()
          set colo to w+/rb,gr+/r
          @ 13,54 clea to 21,75
          @ 13,54 to 21,75 double
          DO WHILE .T.
            pilih=achoice(14,56,20,73,FILD)
            IF LASTKEY()=13
               SCUR=CURC[PILIH]
               EXIT
            ELSE
               IF LASTKEY()=27
                  EXIT
               ELSE
                  LOOP
               ENDIF
            ENDIF
          ENDDO
          SET COLO TO W+/B,W+/N
          RESTSCREEN(0,0,24,79,LYRA)
          SELE 1
          @ 21,50 SAY SCUR
          IF PPN_YN='Y'
             PPNN=.T.
          ELSE
             PPNN=.F.
          ENDIF
          LAYAR=SAVESCREEN(0,0,24,79)
          choice = 'Y'
          do get_optn with 'SAVE (Y/N)','YN',choice
          if choice = 'Y'
            if rec_lock()
             repl supp_name  with name
             repl supp_tel1  with tel1
             repl supp_tel2  with tel2
             repl supp_tel3  with tel3
             repl supp_fax   with fax
             repl supp_telex with telex
             repl supp_add1  with add1
             repl supp_add2  with add2
             repl supp_city  with city
             repl contact_p  with cont_pr
             repl ppn        with ppnn
             repl term_paymt with termpay
             REPL SUPP_CURR WITH SCUR
            endif
            unlock
          endif
          @ 23,09 clear to 23,69
          RESTSCREEN(0,0,24,79,LAYAR)
          SET COLO TO
       case option = 7   && add
        do while .T.
           kode     = spac(4)
           name     = spac(24)
           tel1     = spac(16)
           tel2     = spac(16)
           tel3     = spac(16)
           fax      = spac(16)
           telex    = spac(12)
           add1     = spac(60)
           add2     = spac(48)
           city     = spac(20)
           cont_pr  = spac(24)
           disc     = ' '
           prdisc   = 0
           disc     = ' '
           ppn_yn   = ' '
           termpay  = 0
           SET COLO TO W+/N,w+/n
           @ 10,22 say kode
           @ 10,42 say name
           @ 12,05 say add1
           @ 13,05 say add2
           @ 14,22 say city
           @ 15,22 say tel1
           @ 16,22 say tel2
           @ 17,22 say tel3
           @ 18,22 say fax
           @ 18,41 SAY telex
           @ 19,22 say cont_pr
           @ 20,22 say ppn_yn
           @ 21,22 say termpay PICT '999'
           set deli off
           SET INTE ON
          @ 10,22 GET KODE PICT '@!'
          READ
          IF KODE=SPAC(4)
             EXIT
          ENDIF
          SEEK KODE
          IF .NOT. EOF()
            LAYAR=SAVESCREEN(0,0,24,79)
            set colo to W+/b,w+/B
            @ 23,09 clea to 23,69
            @ 23,10 SAY 'EXIST'
            WAIT ' '
            SET COLO TO
            RESTSCREEN(0,0,24,79,LAYAR)
            loop
          endif
          if m->kode=space(4)
            exit
          endif
           @ 10,42 GET name PICT '@!'
           @ 12,05 GET add1 PICT '@!'
           @ 13,05 GET add2 PICT '@!'
           @ 14,22 GET city PICT '@!'
           @ 15,22 GET tel1 PICT '@!'
           @ 16,22 GET tel2 PICT '@!'
           @ 17,22 GET tel3 PICT '@!'
           @ 18,22 GET fax
           @ 18,41 GET telex
           @ 19,22 GET cont_pr
           DO WHILE .T.
             @ 20,22 GET ppn_yn PICT '@!'
             READ
             IF PPN_YN='Y' .OR. PPN_YN='N'
                EXIT
             ENDIF
           ENDDO
           @ 21,22 get termpay PICT '999'
          read

          LYRA=SAVESCREEN(0,0,24,79)

          F2='CURRENCY'
          SELE 2
          SET EXCLU OFF
          USE &DR&F2
          COUNT TO CNT
          DECLARE FILD[CNT]
          DECLARE CURC[CNT]
          GO TOP
          CR=0
          DO WHILE .NOT. EOF()
             CR=CR+1
             FILD[CR]=SUBS(CURR_COUN,1,14)+' '+CURR_CODE
             CURC[CR]=CURR_CODE
             SKIP
          ENDDO
          set colo to w/b
          inkey()
          set colo to w+/rb,gr+/r
          @ 13,54 clea to 21,75
          @ 13,54 to 21,75 double
          DO WHILE .T.
            pilih=achoice(14,56,20,73,FILD)
            IF LASTKEY()=13
               SCUR=CURC[PILIH]
               EXIT
            ELSE
               LOOP
            ENDIF
          ENDDO
          SET COLO TO W+/B,W+/N
          RESTSCREEN(0,0,24,79,LYRA)
          SELE 1
          @ 21,50 SAY SCUR



          IF PPN_YN='Y'
             PPNN=.T.
          ELSE
             PPNN=.F.
          ENDIF
        LAYAR=SAVESCREEN(0,0,24,79)
          choice = 'Y'
          do get_optn with 'SAVE (Y/N)','YN',choice

          if choice = 'Y'
            if fil_lock()
               append blank
            endif
            if rec_lock()
             repl supp_code  with kode
             repl supp_name  with name
             repl supp_tel1  with tel1
             repl supp_tel2  with tel2
             repl supp_tel3  with tel3
             repl supp_fax   with fax
             repl supp_telex with telex
             repl supp_add1  with add1
             repl supp_add2  with add2
             repl supp_city  with city
             repl contact_p  with cont_pr
             repl ppn        with ppnn
             repl term_paymt with termpay
             REPL SUPP_CURR WITH SCUR
            endif
            unlock
          endif
          @ 23,09 clear to 23,69
          RESTSCREEN(0,0,24,79,LAYAR)
          loop
        enddo
      case option = 8
        LAYAR=SAVESCREEN(0,0,24,79)
        choice = 'N'
        do get_optn with 'Delete (Y/N)','YN',choice
        if choice = 'Y'
          if rec_lock(0)
           delete
          endif
          unlock
          del_rec = 'Y'
          go bottom
        endif
        RESTSCREEN(0,0,24,79,LAYAR)
      other
        loop
    endcase
  enddo
  close index
  close data
  set inte on
   return
